<template>
  <div>
    <login></login>
    <!--视频-->
    <div class="block">
      <!--标题-->
      <div class="title">{{ obj.title }}</div>
      <!--视频-->
      <onDemand class="Demand" v-if="vid" :vid="vid" :playsafe="playsafe" :viewerInfo="viewerInfo"
                :loading_bg_img="loading_bg_img"></onDemand>
      <!--介绍-->
      <div class="mainBody">
        <div class="explain" v-if="obj.duration">
          <span>时长：{{ obj.duration }}</span>
        </div>
        <div class="block2" v-if="obj.descVr">
          <div class="introduce">
            <span>|</span>
            <span>视频介绍</span>
          </div>
          <div class="text">{{ obj.descVr }}</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
//Base64
import {api, httpGet, httpPost} from "../api/http";

let Base64 = require('js-base64').Base64;

import onDemand from "../element/onDemand.vue";
import login from '../element/login'

export default {
  components: {onDemand, login},
  data() {
    return {
      defaultMap: '../../static/img/学术会议.jpg',
      obj: '',
      phone: '',
      //
      vid: '',
      playsafe: '',
      viewerInfo: {
        viewerId: '',
      },
      loading_bg_img: ''
    };
  },
  mounted() {
    this.participationQuestionnaire()
  },
  methods: {
    //获取视频参数
    GetLive(activityId, phone) {
      httpPost(api.info + activityId + '/' + phone, '',).then((res) => {
        if (res.data.code == 200) {
          this.obj = res.data.data
          this.vid = res.data.data.vid
          this.playsafe = res.data.data.playSafeToken
          this.viewerInfo.viewerId = phone
          this.loading_bg_img = res.data.data.guideImgVr
        } else if (res.data.code == 50003) {
          this.$store.state.isActive = true
        }
      })
    },
    //判断是否登录
    participationQuestionnaire() {
      httpGet(api.phone).then((res) => {
        if (res.data.code == 200) {
          this.phone = res.data.data
          let parameter = JSON.parse(Base64.decode(decodeURIComponent(window.location.href.split('?')[1])))
          this.GetLive(parameter.activityId, this.phone)
        } else if (res.data.code == 50003) {
          this.$store.state.isActive = true
        }
      })
    },
  },
};
</script>
<style lang="less" scoped>
.block {
  font-family: PingFangSC;
  margin: 50px 25px;

  .title {
    font-size: 34px;
    font-weight: 800;
  }

  .img {
    width: 100%;
    height: 400px;
    margin: 20px 0;

    .cover {
      width: 100%;
      height: 100%;
      background-color: rgba(47, 47, 47, 0.5);
      opacity: 0.5;
      position: relative;
      top: -5.4rem;
      background-image: url("../../static/img/播放.png");
      background-repeat: no-repeat;
      background-size: 100px;
      background-position: center center;
    }
  }

  #player {
    margin: 20px 0;
  }

  .mainBody {
    font-weight: 400;
    font-style: normal;
    line-height: 46px;
    text-decoration: none;

    .explain {
      span {
        font-size: 24px;
        color: rgb(153, 153, 153);
        margin: 12px 0;
        display: block;
      }
    }

    .block2 {
      margin-bottom: 25px;

      .introduce {
        font-size: 25px;
        font-weight: 600;
        color: rgba(65, 128, 255, 1);
      }

      .text {
        font-size: 24px;
        margin-left: 20px;
      }
    }
  }
}
</style>
